/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package finder;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Alex
 */
public class FilterDescription 
{
    private ArrayList<FilterStage> stages = new ArrayList<>(); 
    public FilterDescription()
    {
        
    }
    public ArrayList<FilterStage> getStages()
    {
        return stages;
    }
    public List<String> find(String url)
    {
        List<String> results = new ArrayList<>();
        if(stages.isEmpty())
            return results;
        results.add(url);
        for(int x = 0; x < stages.size();x++)
        {
            ArrayList<String> currentLevel = new ArrayList<>();
            FilterStage currentStage = stages.get(x);
            for(int i = 0; i < results.size();i++)
                currentLevel.addAll(currentStage.doStage(results.get(i)));
            results = currentLevel;
            if(currentStage.isResultLinkable() == false)
                break;
        }
        return results;
    }   
    
}
